<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Food Addition!</title>

<script language="javascript">
function validate() {
	var isNameValid = validateName();
	var isPriceValid = validatePrice();
	return (isNameValid && isPriceValid);
}

function validateName() {
	var name = document.getElementById("name").value;
	if (name == "") {
		alert("Food name cannot not be empty!");
		return false;
	}
	return true;
}

function validatePrice() {
	var price = document.getElementById("price").value;
	if (price == "") {
		alert("Price cannot be empty!");
		return false;
	}
	price = parseFloat(price);
	if (price < 0) {
		alert("Price should be non-negative!");
		return false;
	}
	return true;
}

</script>

</head>

<body>
<p align = center><a href="index.jsp"><img height="118" src="Pics/restaurantLogo.JPG" width="242" border="0"></a></p>
<form name="foodAddition" method="post" action="./servlet/FoodAddition" onsubmit="return validate(this)">
<table width="521" align="center">
	  <tr>
	    <td width="181">Food Name: </td>
	    <td width="332"><input type="text" name="name" /></td>
  </tr>
	  <tr>
	    <td>Description: </td>
	    <td><textarea name="description" cols="45" rows="5"></textarea></td>
  </tr>
	  <tr>
	    <td>Price: </td>
	    <td><input type="text" name="price" /></td>
  </tr>
	 <tr>
	    <td colspan="2"><table width="520" border="0">
	      <tr>
	        <td width="284" align="center"><label>
	          <input type="submit" value="Submit" />
            </label></td>
	        <td width="226"><label>
	          <input type="reset" value="Reset" />
            </label></td>
          </tr>
       </table></td>
    </tr>
</table>
</form>
</body>
</html>
